# -*- coding: utf-8 -*-
class Box_init():
    def __init__(self, m_client, redis_client):
        self.m_client = m_client

    # 盒子初始化 分开初始化
    def box_init(self):

        # 初始化mongo
        r1 = self.init_mongo()
        # 初始化 redis
        # r2 = self.init_redis()
        if r1:  # and r2:
            return True
        else:
            return False

    def init_mongo(self):
        try:
            print("初始化mongo中...")
            client = self.m_client
            # client.drop_all()
            client.init_mongo()
        except Exception as e:
            print("初始化mongo失败", str(e))
            raise Exception(str(e))
        else:
            print("初始化mongo完毕")
            return True

    # def init_redis(self):
    #     try:
    #         print("清除redis数据")
    #         client = self.redis_client
    #         result = client.flush_all()
    #     except Exception as e:
    #         print("初始化redis失败", str(e))
    #         raise Exception(str(e))
    #     else:
    #         print("初始化redis完毕")
    #         return result
